package net.hn.hnms.biz.emgcy.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.emgcy.domain.ChamberInfoPo;
import net.hn.hnms.biz.emgcy.domain.dto.ChamberInfoDto;
import net.hn.hnms.biz.emgcy.domain.vo.ChamberInfoVo;
import net.hn.hnms.biz.emgcy.service.ChamberInfoService;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: baijiajun
 * @Date: 2022/9/20
 */
@Api(value = "避难硐室模块", tags = {"避难硐室"})
@RestController
@RequestMapping("chamberInfo")
public class ChamberInfoController {
    @Resource
    private ChamberInfoService chamberInfoService;
    @ApiOperation("避难硐室列表")
    @GetMapping("pageList")
    public R<ResponsePage<ChamberInfoVo>> pageList(PageQuery pageQuery, ChamberInfoDto chamberInfoDto) {
        ResponsePage<ChamberInfoVo> list= chamberInfoService.pageList(pageQuery,chamberInfoDto);
        return R.ok(list);
    }

    @ApiOperation("避难硐室添加")
    @PostMapping("/add")
    public R add(@RequestBody ChamberInfoPo chamberInfoPo){
        Boolean flag = chamberInfoService.add(chamberInfoPo);
        if(flag){
            return R.ok("新增成功");
        }
        return R.fail("新增失败");
    }

    @ApiOperation("避难硐室修改")
    @PutMapping("/update")
    public R update(@RequestBody ChamberInfoPo chamberInfoPo){
        Boolean flag = chamberInfoService.update(chamberInfoPo);
        if(flag){
            return R.ok("修改成功");
        }
        return R.fail("修改失败");
    }
    @ApiOperation("避难硐室删除")
    @DeleteMapping("/delete/{id}")
    public R delete(@PathVariable Long id){
        Boolean flag = chamberInfoService.delete(id);
        if(flag){
            return R.ok("删除成功");
        }
        return R.fail("删除失败");
    }
}
